<%@ page language="java" import="java.util.*" pageEncoding="utf-8"
	isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
    String path = request.getContextPath();
			String basePath = request.getScheme() + "://"
					+ request.getServerName() + ":" + request.getServerPort()
					+ path + "/";
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="<%=request.getContextPath()%>/css/style.css" rel="stylesheet" type="text/css" />
<link href="<%=request.getContextPath()%>/css/select.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.idTabs.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/select-ui.min.js"></script>
<script type="text/javascript">
	function chongzhi(a){
		var recharge_money = $(a).val(); 
		if(!/^\d+$/.test(recharge_money)){ 
			alert("请输入正整数");
			$(a).val($(a).next().val());return;
		}
	}
	
	function zengsong(a){
		var present_money = $(a).val();
		if(!/^\d+$/.test(present_money)){ 
			alert("请输入正整数");
			$(a).val($(a).next().val());return;
		}
	}
	
	function chongzhis(a){
		var recharge_money = $(a).val(); 
		if(!/^\d+$/.test(recharge_money)){ 
			alert("请输入正整数");
			$(a).val($(a).next().val());return;
		}
	}
	
	function zengsongs(a){
		var present_money = $(a).val();
		if(!/^\d+$/.test(present_money)){ 
			alert("请输入正整数");
			$(a).val($(a).next().val());return;
		}
	}
</script>
</head>

<body>

	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><e>首页</e></li>
    <li><e>财务管理</e></li>
    <li><e>充值设置</e></li>                                        
    </ul>
    </div>
    
    <div class="formbody">
    
    
    <div id="usual1" class="usual"> 
    
    <div class="itab">
  	<ul> 
    <li><a  id="a" href="#tab1" class="selected" onclick="cz()"   style="font-size:15;    color: #000;">充值设置</a></li> 
     <li><a id="s" href="#tab1" class="selected" onclick="hd()"   style="font-size:15;    color: #000;">活动设置</a></li> 
     <li ><a id="d" href="#tab1" class="selected" onclick="nf()"   style="font-size:15;    color: #000;">年费设置</a></li> 
  	</ul>
    </div> 
    
  	<div id="tab1" class="tabson">
    <ul class="forminfo">
    <li>默认</li>
    <c:forEach items="${lists}" var="data">
    <li>充值
    	<input name="id" type="hidden" value="${data.id}"/>
    	<input name="life" type="hidden" value="${data.service_life}"/>
    	<input name="recharge_money" onchange="chongzhi(this)" type="text" class="dfinput" style="width:50px;height:20px;" value="${data.recharge_money}"/>元，赠送
    	<input type="hidden" value="${data.recharge_money}"/>
    	<input name="present_money" onchange="zengsong(this)"  type="text" class="dfinput" style="width:50px;height:20px;" value="${data.present_money}"/>元优惠券&nbsp;&nbsp;&nbsp;&nbsp;
    	<input type="hidden" value="${data.present_money}"/>
    	<a href="/htx-backer/ui/discount/discount.jsp?common_discount_id=${data.id}&money=${data.present_money}" style="font-weight:bolder;color:blue;cursor:pointer;">设置优惠券面额</a>
    </li>
    <li>优惠券使用期限：
    	<input class="comment" name="yi" value="1" type="checkbox">1个月&nbsp;&nbsp;&nbsp;&nbsp;</input><input class="comment" name="er" value="2" type="checkbox">2个月</input>&nbsp;&nbsp;&nbsp;&nbsp;
    	<input class="comment" name="san" value="3" type="checkbox">3个月&nbsp;&nbsp;&nbsp;&nbsp;</input><input class="comment" name="liu" value="6" type="checkbox">6个月</input>&nbsp;&nbsp;&nbsp;&nbsp;
    </li>
    </c:forEach>
        <li>   启用：<input name="radio" type="radio" class="qiyong"  value="1" />
    &nbsp;&nbsp;&nbsp;&nbsp;    停用：<input name="radio" type="radio" class="tingyong"  value="0" /> </li>
    </ul>
    <div style="margin-left:30px;margin-top:-20px;"><input name="" type="button" class="tijiao" value="提交" style="width:96px; height:35px; line-height:35px; color:#fff; background:red; font-size:14px; font-weight:bold;border-radius: 3px; cursor:pointer;"/>
    </div> 
    </hr>
    </div>
    <li class="a" style="margin-left:100px;">个人vip1年费
    	<input id="vipersid" name="vipersid" type="hidden" value="${selectSetting[0].id}"/>
    	<input name="viptype" id="viptype"  type="hidden"  value="${selectSetting[0].is_auth}"/>
    	<input name="recharge_money" id="vipersmoney" onchange="chongzhi(this)" type="text" class="dfinput" style="width:50px;height:20px;" value="${selectSetting[0].is_auth==1 ?selectSetting[0].money:''}" />元<!-- ，赠送 -->
    	<input type="hidden" value="${data.recharge_money}"/>
    	<input style="display:none;" name="present_money" onchange="zengsong(this)"  type="text" class="dfinput" style="width:50px;height:20px;" value="${data.present_money}"/><!-- 元优惠券 -->&nbsp;&nbsp;&nbsp;&nbsp;
    	<input type="hidden" value="${data.present_money}"/>
    	<a style="display:none;" href="" style="font-weight:bolder;color:blue;cursor:pointer;">设置优惠券面额</a>
    </li>
        <li class="a" style="margin-left:100px;">个人vip2年费
    	<input id="vipersid3" name="vipersid3" type="hidden" value="${selectSetting[2].id}"/>
    	<input name="viptype3" id="viptype3"  type="hidden"  value="${selectSetting[2].is_auth}"/>
    	<input name="recharge_money" id="vipersmoney3" onchange="chongzhi(this)" type="text" class="dfinput" style="width:50px;height:20px;" value="${selectSetting[2].is_auth==3 ?selectSetting[2].money:''}" />元<!-- ，赠送 -->
    	<input type="hidden" value="${data.recharge_money}"/>
    	<input style="display:none;" name="present_money" onchange="zengsong(this)"  type="text" class="dfinput" style="width:50px;height:20px;" value="${data.present_money}"/><!-- 元优惠券 -->&nbsp;&nbsp;&nbsp;&nbsp;
    	<input type="hidden" value="${data.present_money}"/>
    	<a style="display:none;" href="" style="font-weight:bolder;color:blue;cursor:pointer;">设置优惠券面额</a>
    </li>
     <li class="a" style="margin-left:100px;margin-top:10px;">企业年费
    	<input  id="vipentid" name="vipentid" type="hidden" value="${selectSetting[1].id}"/>
    	<input name="viptypes" id="viptypep"  type="hidden" value="${selectSetting[1].is_auth}"/>
    	<input name="recharge_money"  id="vipentmoney" onchange="chongzhi(this)" type="text" class="dfinput" style="width:50px;height:20px;" value="${selectSetting[1].is_auth==2?selectSetting[1].money:''}"/>元<!-- ，赠送 -->
    	<input type="hidden" value="${data.recharge_money}"/>
    	<input style="display:none;" name="present_money" onchange="zengsong(this)"  type="text" class="dfinput" style="width:50px;height:20px;" value="${data.present_money}"/><!-- 元优惠券 -->&nbsp;&nbsp;&nbsp;&nbsp;
    	<input type="hidden" value="${data.present_money}"/>
    	<a style="display:none;" href="" style="font-weight:bolder;color:blue;cursor:pointer;">设置优惠券面额</a>
    </li>
    <li class="a" style="margin-left:100px;margin-top:20px;">
    <input name="" type="button" class="viptijiao" onclick="viptijiao();" value="提交" style="width:96px; height:35px; line-height:35px; color:#fff; background:red; font-size:14px; font-weight:bold;border-radius: 3px; cursor:pointer;"/>
    </li>
    <div id="tab2" class="tabson" >
    <ul class="forminfo" style="margin-top:-40px;">
    <li><strong style="color:red">活动时间：</strong><td><input type="date" name="startTime" value="${activity.start_time}" style="border:1px solid #d7a372;"/>至
    <input type="date" name="endTime" value="${activity.end_time}" style="border:1px solid #d7a372;"/></td></li>
    <c:forEach items="${list}" var="list">
    <li>充值
    	<input name="id" type="hidden" value="${list.id}"/>
    	<input name="lifes" type="hidden" value="${list.service_life}"/>
    	<input name="recharge_moneys" onchange="chongzhis(this)" type="text" class="dfinput" style="width:50px;height:20px;" value="${list.recharge_money}"/>元，赠送
    	<input type="hidden" value="${list.recharge_money}"/>
    	<input name="present_moneys" onchange="zengsongs(this)"  type="text" class="dfinput" style="width:50px;height:20px;" value="${list.present_money}"/>元优惠券&nbsp;&nbsp;&nbsp;&nbsp;
    	<input type="hidden" value="${list.present_money}"/>
    	<a href="/htx-backer/ui/discount/activity_discount.jsp?activity_discount_id=${list.id}&activity_money=${list.present_money}" style="font-weight:bolder;color:blue;cursor:pointer;">设置优惠券面额</a>
    </li>
    <li>优惠券使用期限：
    	<input class="activity" name="yis" value="1" type="checkbox">1个月&nbsp;&nbsp;&nbsp;&nbsp;</input><input class="activity" name="ers" value="2" type="checkbox">2个月</input>&nbsp;&nbsp;&nbsp;&nbsp;
    	<input class="activity" name="sans" value="3" type="checkbox">3个月&nbsp;&nbsp;&nbsp;&nbsp;</input><input class="activity" name="lius" value="6" type="checkbox">6个月</input>&nbsp;&nbsp;&nbsp;&nbsp;
    </li>
    </c:forEach>
       <li>   启用：<input name="radio1" type="radio" class="qiyong"  value="1" />
    &nbsp;&nbsp;&nbsp;&nbsp;    停用：<input name="radio1" type="radio" class="tingyong"  value="0" /> </li>
    </ul>
    <div style="margin-left:30px;margin-top:-20px;"><input name="" type="button" class="submit" value="提交" style="width:96px; height:35px; line-height:35px; color:#fff; background:red; font-size:14px; font-weight:bold;border-radius: 3px; cursor:pointer;"/>
    </div> 
  </div>
  <script type="text/javascript">
  if('${activity}'!=null){
	  var start='${activity.start_time}';
		  var end='${activity.end_time}';
		  start= start.substring(0,10);
		  end=end.substring(0,10);
	  $("input[name=startTime]").val(start);
	  		$("input[name=endTime]").val(end);
  }
  if('${listc}'!=null){
	  if('${listc[0].status }'=='0'){
		  $("input:radio[name=radio][value=0]").attr("checked",true);  
	  }
	  if('${listc[0].status }'=='1'){
		  $("input:radio[name=radio][value=1]").attr("checked",true);  
	  }
	  if('${listc[1].status }'=='0'){
		  $("input:radio[name=radio1][value=0]").attr("checked",true);  
	  }
	  if('${listc[1].status }'=='1'){
		  $("input:radio[name=radio1][value=1]").attr("checked",true);  
	  }
  }
  
  $("#tab1").show();
  $("#tab2").hide();
  $("#a").css("color","azure");
  $("#a").css("background","#EB5409");
  $(".a").hide();
  function cz(){
	  $("#tab1").show();
	  $("#tab2").hide();
	  $(".a").hide();
	  $("#a").css("color","azure");
	  $("#a").css("background","#EB5409");
	  $("#s").css("color","#000");
	  $("#s").css("background","");
	  $("#d").css("color","#000");
	  $("#d").css("background","");
  }
  
  function hd(){
	  $("#tab2").show();
	  $("#tab1").hide();
	  $(".a").hide();
	  $("#s").css("color","azure");
	  $("#s").css("background","#EB5409");
	  $("#a").css("color","#000");
	  $("#a").css("background","");
	  $("#d").css("color","#000");
	  $("#d").css("background","");
  }
 function nf(){
	 $(".a").show();
	  $("#tab1").hide();
	  $("#tab2").hide();
	  $("#d").css("color","azure");
	  $("#d").css("background","#EB5409");
	  $("#a").css("color","#000");
	  $("#a").css("background","");
	  $("#s").css("color","#000");
	  $("#s").css("background","");
	 
  }
  	$(function(){
  		$(":checkbox").click(function(){ 
  			if($(this).attr("checked") != undefined){ 
  				$(this).siblings().attr("checked",false); 
  				$(this).attr("checked",true); 
  			} 
  		}); 
  		
  		$("input[name=life]").each(function(index,domEle){
	  		var nums = $(domEle).val();
	  		if(nums == 1){
	  			$(domEle).parent().next().find("input[name=yi]").attr("checked",true);
	  		}
	  		if(nums == 2){
	  			$(domEle).parent().next().find("input[name=er]").attr("checked",true);
	  		}
	  		if(nums == 3){
	  			$(domEle).parent().next().find("input[name=san]").attr("checked",true);
	  		}
	  		if(nums == 6){
	  			$(domEle).parent().next().find("input[name=liu]").attr("checked",true);
	  		}
  		});
  		
  		$("input[name=lifes]").each(function(index,domEle){
	  		var nums = $(domEle).val();
	  		if(nums == 1){
	  			$(domEle).parent().next().find("input[name=yis]").attr("checked",true);
	  		}
	  		if(nums == 2){
	  			$(domEle).parent().next().find("input[name=ers]").attr("checked",true);
	  		}
	  		if(nums == 3){
	  			$(domEle).parent().next().find("input[name=sans]").attr("checked",true);
	  		}
	  		if(nums == 6){
	  			$(domEle).parent().next().find("input[name=lius]").attr("checked",true);
	  		}
  		});
  		
  		$(".tijiao").click(function(){
  			var recharge_money = "",present_money = "",service_life = "";
  	  		$("input[name=recharge_money]").each(function(index,domEle){
  		  		recharge_money += $(domEle).val() + ",";
  	  		});
  	  		$("input[name=present_money]").each(function(index,domEle){
  	  			present_money += $(domEle).val() + ",";
  	  		});
  	  		$.each($(".comment:checked"),function(){
  	  			service_life += $(this).val() + ",";
        	});
  			$.ajax({
  				type:"get",
  				url:"/htx-backer/setCommontDiscount", 
  				data:{
  					recharge_money:recharge_money,
  					present_money:present_money,
  					service_life:service_life,
  					status:$("input[name='radio']:checked").val(),
  					id:1,
  				},
  				dataType:"json",
  				success:function(data){
  					if(data.flag > 0){
  					 	var btn = confirm("提交成功,点击返回充值设置!")
		   				window.location.href="/htx-backer/selectCommontDiscount";
  					}
  				}
			}) 
  		})
  		
  		$(".submit").click(function(){
  			var recharge_money = "",present_money = "",service_life = "";
  	  		$("input[name=recharge_moneys]").each(function(index,domEle){
  		  		recharge_money += $(domEle).val() + ",";
  	  		});
  	  		$("input[name=present_moneys]").each(function(index,domEle){
  	  			present_money += $(domEle).val() + ",";
  	  		});
  	  		$.each($(".activity:checked"),function(){
  	  			service_life += $(this).val() + ",";
        	});
  	  		var start_time = $("input[name=startTime]").val();
  	  		var end_time = $("input[name=endTime]").val();
  	  		if(start_time == "" || end_time == ""){
	  	  		alert("请选择活动开始时间和结束时间");
  	  		}
  			$.ajax({
  				type:"get",
  				url:"/htx-backer/setActivityDiscount", 
  				data:{
  					recharge_money:recharge_money,
  					present_money:present_money,
  					service_life:service_life,
  					start_time:start_time,
  					end_time:end_time,
  					status:$("input[name='radio1']:checked").val(),
  					id:2,
  				},
  				dataType:"json",
  				success:function(data){
  					if(data.flag > 0){
  					 	var btn = confirm("提交成功,点击返回充值设置!")
		   				window.location.href="/htx-backer/selectCommontDiscount";
  					}
  				}
			}) 
  		})
  	})
  	function viptijiao(){
  		if($("#vipentmoney").val()==null||$("#vipentmoney").val()==""){
  			$("#vipentmoney").val(0);
  		}
  		if($("#vipersmoney").val()==null||$("#vipersmoney").val()==""){
  			$("#vipersmoney").val(0);
  		}
  		$.ajax({
				type:"get",
				url:"/htx-backer/OrVipSettingAddUpdate", 
				data:{
					money1:$("#vipersmoney").val(),
					money2:$("#vipentmoney").val(),
					money3:$("#vipersmoney3").val(),
					id1:$("#vipersid").val(),
					id2:$("#vipentid").val(),
					id3:$("#vipersid3").val(),
					is_auth1:$("#viptype").val(),
					is_auth2:$("#viptypep").val(),
					is_auth3:$("#viptype3").val(),
				},
				dataType:"json",
				success:function(data){
					if(data.flag > 0){
					 	var btn = confirm("提交成功,点击返回充值设置!")
	   				window.location.href="/htx-backer/selectCommontDiscount";
					}
				}
		}) 
  	}
  </script>
</body>
</html>
